<?PHP
/*
  Plugin for download from example website (http://example.com/)
  Developed by Anonymous <anonymous at example dot com - http://example.com>
*/

$plugins[] = array('example','@http://example.com/files/.+@');

/*
 This function returns a array:
    [status]       => one constant from include/defines.php
    [status_error] => the error message. Only if status == STATUS_ERROR
    [content]      => the file. Only if status != STATUS_ERROR
    [filePath]     => the filename. Optional
*/
function example_download($url, $extra)
{
    $file = downloadUrl($url);
    if(($file['code']<200) or ($file['code']>299)) {
        return array(
                        'status'       => STATUS_ERROR,
                        'status_error' => 'Download error. Response code #'.$file['code'],
        );
    }else{
        return array(
                        'status'  => STATUS_DOWNLOADED,
                        'content' => $file['content']
        );
    }
}

/*
 This function returns the file name
*/
function example_getName($url)
{
    return strpos($url,'?') ? strstr(basename($url),'?',true) : basename($url);

}
?>